<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
window.returnValue=0;
var versusBattlePointId = null;
var getversusBattlePointUrl = "/versusBattlePoint/get/";
var editversusBattlePointUrl = "/versusBattlePoint/edit/";
var currentversusBattlePoint = null;
$(document).ready(function() {
	versusBattlePointId = window.dialogArguments;
	$.ajax({
		   type: "GET",
		   url: getversusBattlePointUrl,
		   data: "versusBattlePointId=" + versusBattlePointId,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   var result = data.result;
				   $("#versusBattlePointId").val(result.versusBattlePointId);
				   $("#deployId").val(result.deployId);
				   $("#level").val(result.level);
				   $("#battlePointId").val(result.battlePointId);
				   				   
				   currentversusBattlePoint = result; 
				   listselectors();
				   window.returnValue=1;
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
});

function listselectors() {
var getCampaignSelectorUrl = "/special/Campaign/getList/";
$.ajax({
		   type: "GET",
		   url: getCampaignSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectbattlePointId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

function editversusBattlePoint() {
	var versusBattlePointIdParam = "versusBattlePointId=" + versusBattlePointId;
	var levelValue = $("#level").val();
	if(!checkInteger("等级",levelValue,false)) {
		return;
	}
	var levelParam = "level=" + xparseInt(levelValue);
		
	var battlePointIdValue = $("#battlePointId").val();
	
	var battlePointIdParam = "battlePointId=" + battlePointIdValue;
			
	$.ajax({
		   type: "POST",
		   url: editversusBattlePointUrl,
		   		   data:  versusBattlePointIdParam + '&' +  levelParam  +'&'+   battlePointIdParam  ,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
			   	   beforeWindowClose();
				   window.close();
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

	
			function selectbattlePointId(options) {
			var optionHTML = "";
			for(var i in options) {
				optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
			}
			$("#battlePointId").html(optionHTML);
			if(currentversusBattlePoint != undefined) {
				$("#battlePointId").val(currentversusBattlePoint.battlePointId);
			}
		}
	
function openResource(fieldname,dependfield) {
	if(dependfield == null || dependfield == 'None') {
		return;
	}
	var param = $("#" + dependfield).val()
	if(param == null || param == "") {
		alert("你先把【" + $("#lbl_" + dependfield).html() + "】填了再上传");
		return;
	}
	resourceDialog("versusBattlePoint",$("#" + fieldname).val(),param,function(result) {
		if(result != undefined && result != "") {
			$("#" + fieldname).val(result);
		}
	});
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<form action="/versusBattlePoint/add" method="post">
		<table>
			<tbody>
				<tr>
					<td>ID</td><td><input type="text" id="versusBattlePointId" name="versusBattlePointId" disabled/></td>
					<td>发布Id</td><td><input type="text" id="deployId" name="deployId" disabled/></td>
				</tr>
			</tbody>
		</table>
		<table>
			<tbody>				
					<tr>					<td>
						<label for="level" id="lbl_level">等级</label>
													<input type="text" id="level" name="level" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="battlePointId" id="lbl_battlePointId">战役点</label>
													<select id="battlePointId" name="battlePointId">
							</select>
											</td>
					</tr>							</tbody>
		</table>
		<input type="button" onclick="editversusBattlePoint()" value="修改"/>
	</form>
	</div>
</body>